package com.hongtech.framework.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        /* 创建时间 */
        Date nowTime = new Date();
        this.strictInsertFill(metaObject, "createTime", Date.class, nowTime);
        this.strictInsertFill(metaObject, "updateTime", Date.class, nowTime);
    }


    @Override
    public void updateFill(MetaObject metaObject) {
        /* 更新时间 */
        Date nowTime = new Date();
        this.strictUpdateFill(metaObject, "updateTime", Date.class, nowTime);
    }

}

